package com.wawei.seeds.utils;

import android.app.Activity;
import android.content.Context;
import android.view.inputmethod.InputMethodManager;

import com.wawei.seeds.R;

/**
 * Created by t27891 on 15/7/21.
 */
public class WalnutUtils {
    private static final String APPOINTMENT_STATUS_APPLY = "apply";
    private static final String APPOINTMENT_STATUS_ACCEPT = "accepted";
    private static final String APPOINTMENT_STATUS_REJECT = "rejected";
    private static final String APPOINTMENT_STATUS_DONE = "done";
    private static final String APPOINTMENT_STATUS_CANCEL = "cancel";

    public static String transformServiceStatus(final Context context, String original){
        if(APPOINTMENT_STATUS_APPLY.equals(original)){
            return context.getResources().getText(R.string.walnut_appointment_status_apply).toString();
        }
        else if(APPOINTMENT_STATUS_ACCEPT.equals(original)){
            return context.getResources().getText(R.string.walnut_appointment_status_accept).toString();
        }
        else if(APPOINTMENT_STATUS_REJECT.equals(original)){
            return context.getResources().getText(R.string.walnut_appointment_status_reject).toString();
        }
        else if(APPOINTMENT_STATUS_DONE.equals(original)){
            return context.getResources().getText(R.string.walnut_appointment_status_done).toString();
        }
        else if(APPOINTMENT_STATUS_CANCEL.equals(original)){
            return context.getResources().getText(R.string.walnut_appointment_status_cancel).toString();
        }
        return "";
    }

    public static void closeInputMethod(final Activity activity) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        boolean isOpen = imm.isActive();
        if (isOpen) {
            // imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);//没有显示则显示
            imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
}
